/*
 * ElectrolyteSolution.h
 *
 *  Created on: 19 Aug 2011
 *      Author: Allan
 */

#ifndef ELECTROLYTESOLUTION_H_
#define ELECTROLYTESOLUTION_H_

// C++ includes
#include <string>
#include <vector>
using namespace std;

// Eigen includes
#include <Eigen/Core>
using namespace Eigen;

// GeoReact includes
#include "Types.h"

class ElectrolyteSolution
{
public:
	ElectrolyteSolution();
	
	explicit ElectrolyteSolution(const vector<string>& species);
	
	const vector<string>&
	GetSpecies() const;
	
	const vector<string>&
	GetIons() const;
	
	const vector<string>&
	GetComplexes() const;
	
	const VectorXd&
	GetIonicCharges() const;
	
	const Index
	GetWaterIndex() const;
	
	const double
	EffectiveIonicStrength(const VectorXd& n) const;
	
	const double
	StoichiometricIonicStrength(const VectorXd& n) const;
	
	const VectorXd
	IonicMolalities(const VectorXd& n) const;
	
	const VectorXd
	StoichiometricIonicMolalities(const VectorXd& n) const;
	
	const VectorXd
	Molalities(const VectorXd& n) const;
	
private:
	/// The species in the electrolyte solution
	vector<string> species;
	
	/// The indexes of the ions and complexes in the electrolyte solution
	vector<Index> idxions, idxcomplexes;
	
	/// The ions and complexes in the electrolyte solution
	vector<string> ions, complexes;
	
	/// The index of the water species
	Index iH2O;
	
	/// The vector of electrical charges of the ionic species
	VectorXd zi;
	
	/// The stoichiometric matrix between the complexes and ions
	MatrixXd vci;
};

//===============================================//
// Methods
//===============================================//
const VectorXd
ElectricalCharges(const vector<string>& ions);

const MatrixXd 
StoichiometricMatrixComplexesIons(const vector<string>& complexes, const vector<string>& ions);

#endif /* ELECTROLYTESOLUTION_H_ */
